#ifndef _COMMON_H
#define _COMMON_H

#define  N  64
#define  R  1   //  user register
#define  L  2   //  user login
#define  Q  3   //  query word
#define  A  4   //  history record
#define  M  5
#define  D  6
#define DATABASE "user_info"

#define err_log(errlog)\
	do {\
		printf("%s: %s --> %d\n", __FILE__, __func__, __LINE__);\
		perror(errlog);\
	}while(0)


typedef struct {
	int root;
	int type; // 
	char name[N];  // 姓名	
	char password[N]; // 密码
	char addr[N]; // 地址	
	char age; // 年龄	
	int level; // 等级	
	int no; //编号	
	char phone[N]; // 电话	
	double salary ; // 工资
	char data[256];
}USER_INFO;

extern int create_open_database(const char* db_name, sqlite3** db);
// Register
extern void do_register(int connectfd, USER_INFO *user_info, sqlite3 *db);
// Login
extern void do_login(int connectfd, USER_INFO *user_info, sqlite3 *db);
extern int login_callback(void *arg, int f_num, char **f_value, char **f_name);

// Querry
extern void do_querry(int connectfd, USER_INFO *user_info, sqlite3 *db);
extern void do_querry_xxdk(int connectfd, USER_INFO *user_info, sqlite3 *db);
extern int querry_callback(void *arg, int f_num, char ** f_value, char ** f_name);
extern int querry_callback_xxdk(void *arg, int f_num, char ** f_value, char ** f_name);
// Add
extern void do_add(int connectfd, USER_INFO *user_info, sqlite3 *db);
// Modify
extern void do_modify(int connectfd, USER_INFO *user_info, sqlite3 *db);

// Delete
extern int  do_delete(int connectfd, USER_INFO *user_info, sqlite3 *db);
// 
extern void do_client(int connectfd, sqlite3 *db);

#endif

